package com.thread.sync.sync02;


public class Synch01 {

    public synchronized void method1() {
        System.out.println("----method1");
        method2();
    }

    public synchronized void method2() {
        System.out.println("----method2");
        method3();
    }

    public synchronized void method3() {
        System.out.println("----method3");
    }

    //此线程获取锁之后执行method1,方法里面调用method2时,需要再次获得该对象的锁,是可以获取到的
    public static void main(String[] args) {
        Synch01 sy = new Synch01();
        new Thread(new Runnable() {
            @Override
            public void run() {
                sy.method1();
            }
        }).start();
    }
}
